<template>
  <header class="header">
    <h1>todos</h1>
    <input
      class="new-todo"
      placeholder="请输入任务名称"
      autofocus
      v-model.trim="task"
      @keyup.enter="addtask(task)"
    />
  </header>
</template>

<script>
export default {
  name: 'MyHeader',
  data () {
    return {
      task: ''
    }
  },
  methods: {
    addtask (task) {
      this.$emit('addtask', task)
      this.task = ''
    }
  }
}
</script>

<style scoped lang="less"></style>
